Skip to content

Fix "amsgrad" is used before being defined when initializing the AdamW optimizer#660

Merged
chaoming0625 merged 3 commits intobrainpy:masterfrom
CloudyDory:master
Mar 29, 2024
Merged

Fix "amsgrad" is used before being defined when initializing the AdamW optimizer#660
chaoming0625 merged 3 commits intobrainpy:masterfrom
CloudyDory:master

Conversation

@CloudyDory
Copy link
Copy Markdown
Contributor

When initializing the "AdamW" optimizer, property "amsgrad" is used before it is defined. Therefore the following code generates error: AttributeError: 'AdamW' object has no attribute 'amsgrad'.

import brainpy as bp
import brainpy.math as bm

weights = {'weight': bm.TrainVar(bm.zeros(10))}
optimizer = bp.optim.AdamW(lr=0.01, train_vars=weights)

This PR fixes this error.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • Code follows the code style of this project.
  • Changes follow the CONTRIBUTING guidelines.
  • Update necessary documentation accordingly.
  • Lint and tests pass locally with the changes.
  • Check issues and pull requests first. You don't want to duplicate effort.

@chaoming0625 chaoming0625 self-requested a review March 29, 2024 06:52
Copy link
Copy Markdown
Member

@chaoming0625 chaoming0625 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fixing.

@chaoming0625 chaoming0625 merged commit b06d80a into brainpy:master Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants